package com.sitech.oncon.barcode.core;

import java.io.IOException;
import java.util.Collection;
import java.util.Hashtable;

import net.wxxr.dataparse.model.DataParseError;
import net.wxxr.dataparse.model.DataState;
import net.wxxr.http.interfaces.ITag;
import net.wxxr.http.request.HttpBaseRequest;
import oauth.signpost.http.HttpParameters;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.provider.MediaStore;
import android.text.ClipboardManager;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.FrameLayout.LayoutParams;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.BinaryBitmap;
import com.google.zxing.ChecksumException;
import com.google.zxing.EncodeHintType;
import com.google.zxing.FormatException;
import com.google.zxing.LuminanceSource;
import com.google.zxing.NotFoundException;
import com.google.zxing.Result;
import com.google.zxing.client.result.ParsedResult;
import com.google.zxing.client.result.ResultParser;
import com.google.zxing.common.HybridBinarizer;
import com.sitech.oncon.barcode.camera.CameraManager;
import com.sitech.oncon.barcode.executor.ResultHandler;
import com.ykdl.member.constant.KidAction;
import com.ykdl.member.constant.KidConfig;
import com.ykdl.member.kid.R;
import com.ykdl.member.kid.beans.GetUser_ScoreBean;
import com.ykdl.member.kid.beans.ResultBean;
import com.ykdl.member.kid.circle.CircleTopicActivity;
import com.ykdl.member.kid.circle.TopicAndResultActivity;
import com.ykdl.member.kid.doctor.DoctorInfoActivity;
import com.ykdl.member.kid.doctor.ToAskDoctorActivity;
import com.ykdl.member.kid.gears.ArticlesActivity;
import com.ykdl.member.kid.gears.ArticlesWebviewActivity;
import com.ykdl.member.kid.gears.BaseScreen;
import com.ykdl.member.kid.gears.GoodLifeActivity;
import com.ykdl.member.kid.gears.HomeActivity;
import com.ykdl.member.kid.gears.InputCodeActivity;
import com.ykdl.member.kid.gears.MyGoodLifeActivity;
import com.ykdl.member.kid.gears.TopicsSheetListActivity;
import com.ykdl.member.kid.marketcard.MarketcardHelpAandIntro;
import com.ykdl.member.kid.util.ActiveStateUtil;
import com.ykdl.member.kid.widget.dialog.DialogImpl;
import com.ykdl.net.manager.TaskManager;
import com.ykdl.net.manager.Wxxr;

public final class CaptureActivity extends BaseScreen implements SurfaceHolder.Callback {

	private static final String TAG = CaptureActivity.class.getSimpleName();
	private CameraManager cameraManager;
	private CaptureActivityHandler handler;
	private ViewfinderView viewfinderView;
	private TextView statusView;
	private TextView common_title_TV_left;
	private TextView common_title_TV_right;
	private Result lastResult;
	private boolean hasSurface;
	private IntentSource source;
	private Collection<BarcodeFormat> decodeFormats;
	private String characterSet;
	private InactivityTimer inactivityTimer;
	private TitleView title;
	//private Button from_gallery;
	private final int from_photo = 010;
	static final int PARSE_BARCODE_SUC = 3035;
	static final int PARSE_BARCODE_FAIL = 3036;
	String photoPath;
	ProgressDialog mProgress;
	private Context mContext;
	private boolean isIntent = false;
	private boolean isShow = true;
	private Button input_code;
	// Dialog dialog;

	enum IntentSource {

		ZXING_LINK, NONE

	}

	Handler barHandler = new Handler() {

		@Override
		public void handleMessage(Message msg) {
			switch (msg.what) {
			case PARSE_BARCODE_SUC:
				//viewfinderView.setRun(false);
				Log.e("CaptureActivity", "--CaptureActivity--2");
				showDialog((String) msg.obj);
				break;
			case PARSE_BARCODE_FAIL:
				//showDialog((String) msg.obj);
				if (mProgress != null && mProgress.isShowing()) {
					mProgress.dismiss();
				}
				new AlertDialog.Builder(CaptureActivity.this).setTitle("��ʾ").setMessage("ɨ��ʧ�ܣ�").setPositiveButton("ȷ��", new DialogInterface.OnClickListener() {

					@Override
					public void onClick(DialogInterface dialog, int which) {
						dialog.dismiss();
					}
				}).show();
				break;
			}
			super.handleMessage(msg);
		}

	};

	ViewfinderView getViewfinderView() {
		return viewfinderView;
	}

	public Handler getHandler() {
		return handler;
	}

	CameraManager getCameraManager() {
		return cameraManager;
	}

	@Override
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);

		// Window window = getWindow();
		// window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
		isShow = this.getIntent().getBooleanExtra("isShow", true);
		setContentView(R.layout.capture);
		mContext = this;
		hasSurface = false;
		inactivityTimer = new InactivityTimer(this);

		cameraManager = new CameraManager(getApplication());

		viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view);
		viewfinderView.setCameraManager(cameraManager);
		statusView = (TextView) findViewById(R.id.status_view);
		common_title_TV_left = (TextView) findViewById(R.id.common_title_TV_left);
		common_title_TV_right = (TextView) findViewById(R.id.common_title_TV_right);
		input_code  = (Button) findViewById(R.id.input_code);
		findViewById(R.id.input_code).setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				go(InputCodeActivity.class);
			}
		});
		//title = (TitleView) findViewById(R.id.decode_title);
		//from_gallery = (Button) findViewById(R.id.from_gallery);
		// Ϊ����͵ײ���ť��Ӽ����¼�
		if (isShow) {
			statusView.setText("请扫描产品防伪条形码 ");
			input_code.setVisibility(View.VISIBLE);
		}else {
			statusView.setText("扫一扫门店二维码,享受门店特权");
			input_code.setVisibility(View.GONE);
		}
		setListeners();
	}

	public void showDialog(final String msg) {

		if (mProgress != null && mProgress.isShowing()) {
			mProgress.dismiss();
		}
		if(msg.startsWith("10001|")){
			String paction=msg.substring(6);
			String[] end = paction.split("\\//")[1].split("\\/");
			Intent intent = null;
			 if (paction.contains("subject")) {//进帖子详情
				 intent =new Intent(mContext,TopicAndResultActivity.class);
				 intent.putExtra(TopicAndResultActivity.STR_TOPIC_ID,end[2]);
				 intent.putExtra(TopicAndResultActivity.STR_GROUP_ID, end[1]);
			} else if (paction.contains("group")) {//进圈子
				intent = new Intent(mContext, CircleTopicActivity.class);
				intent.putExtra(TopicAndResultActivity.STR_GROUP_ID, end[1]);
			} else if (paction.contains("docask")){//医生
				intent = new Intent(mContext, ToAskDoctorActivity.class);
				intent.putExtra("campaign_id", end[1]);
			} else if (paction.contains("docspec")){//医生专题
				intent = new Intent(mContext, TopicsSheetListActivity.class);
				intent.putExtra("catalog_id", end[1]);
			} else if(paction.contains("hotspec")){//普通专题
				intent = new Intent(mContext, TopicsSheetListActivity.class);
				intent.putExtra("catalog_id", end[1]);
			}else if(paction.contains("docintro")){//医生简介
				intent = new Intent(mContext, DoctorInfoActivity.class);
					intent.putExtra("doctor_id", end[1]);
			}else if(paction.contains("docol")){//医生在线
//				dialog = new DialogImpl();
//				progress = (ProgressDialog) dialog.showProgressDialog(this, "请稍等...", new onChannelListener(this));
//				ActiveStateUtil.getInstance(this).gogoActionsDoctorOnlineByStatus(end[2], progress);
			}
			 if(intent ==null)return;
			 startActivity(intent);
			}else if(msg.startsWith("10002|")){
				
			}
			else if(msg.startsWith("10003|")){
				//关闭JS
			}else if(msg.startsWith("10004|")){
				//外部浏览器
				String paction=msg.substring(6);
				Intent intent = new Intent();        
				intent.setAction("android.intent.action.VIEW");    
				Uri content_url = Uri.parse(paction);   
				intent.setData(content_url);  
				startActivity(intent);
			}else if(msg.startsWith("10101|")){
				//二维码兑换
				String paction=msg.substring(6);
				getData(paction);
				isIntent=true;
			}else {
				LinearLayout layout = new LinearLayout(CaptureActivity.this);  
				TextView tv = new TextView(CaptureActivity.this);  
				tv.setText("扫描成功不支持该二维码"); 
				tv.setTextSize(16);
				LinearLayout.LayoutParams pm = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);  
				layout.addView(tv, pm);  
				layout.setGravity(Gravity.CENTER);  
				TextView title = new TextView(CaptureActivity.this);  
			      title.setText("扫描成功");  
			      title.setTextSize(20);
			      title.setGravity(Gravity.CENTER);  
			      
				new AlertDialog.Builder(CaptureActivity.this).setCustomTitle(title) .
				setView(layout).
				setPositiveButton(getString(R.string.confirm), new DialogInterface.OnClickListener() {

					@Override
					public void onClick(DialogInterface dialog, int which) {
						dialog.dismiss();
						if ((source == IntentSource.NONE || source == IntentSource.ZXING_LINK) && lastResult != null) {
							restartPreviewAfterDelay(0L);
						}
					}
				}).show();
			}
		
		/*if(msg.startsWith("http")){
			new AlertDialog.Builder(CaptureActivity.this).setTitle(getString(R.string.memo)).
			setMessage(String.format(getString(R.string.barcode_tow_dimen_success), msg)).
			setPositiveButton(getString(R.string.confirm), new DialogInterface.OnClickListener() {

				@Override
				public void onClick(DialogInterface dialog, int which) {
					dialog.dismiss();
					//	String testUrl = "http://www.on-con.com/oncon/pages/download.jsp";
						Intent intent = new Intent();        
						intent.setAction("android.intent.action.VIEW");    
						Uri content_url = Uri.parse(msg);   
						intent.setData(content_url);  
						startActivity(intent);
						finish();
				}
			}).setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {

				@Override
				public void onClick(DialogInterface dialog, int which) {
					dialog.dismiss();
					if ((source == IntentSource.NONE || source == IntentSource.ZXING_LINK) && lastResult != null) {
						restartPreviewAfterDelay(0L);
					}
				}
			}).show();
			}else{
				new AlertDialog.Builder(CaptureActivity.this).setTitle(getString(R.string.memo)).
				setMessage(String.format(getString(R.string.barcode_one_dimen_success), msg)).
				setPositiveButton(getString(R.string.confirm), new DialogInterface.OnClickListener() {

					@Override
					public void onClick(DialogInterface dialog, int which) {
						dialog.dismiss();
						//��ȡ�����������
						ClipboardManager cm =(ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
						//���ı���ݸ��Ƶ������
						cm.setText(msg);
						//��ȡ��������
						//cm.getText();
							
					}
				}).setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {

					@Override
					public void onClick(DialogInterface dialog, int which) {
						dialog.dismiss();
						if ((source == IntentSource.NONE || source == IntentSource.ZXING_LINK) && lastResult != null) {
							restartPreviewAfterDelay(0L);
						}
					}
				}).show();
			}*/

	}
	public void getData(String code) {
		if (isIntent) {
			return;
		}
		showProgress("正在加载中,请稍等...");
		String  pageurl =KidConfig.SCAN_CODE;
		HttpParameters parameterss = new HttpParameters();
		parameterss.put("code", code);
		HttpBaseRequest request  =  Wxxr.getInstance().postBaseRequest(pageurl,parameterss,null);
		 TaskManager.startHttpRequest(request, new getDataTag(),  ResultBean.class);
	}
	
	class getDataTag implements ITag {

		@Override
		public void refreshUI(Object t, DataState ds) {
			// TODO Auto-generated method stub
			finishProgress();
			if (t instanceof ResultBean) {
				final ResultBean bean = (ResultBean)t;
				if (null==bean.getError()) {
					if (bean.getAction()==1) {
						LinearLayout layout = new LinearLayout(CaptureActivity.this);  
						TextView tv = new TextView(CaptureActivity.this);  
						tv.setText(bean.getMessage());  
						tv.setTextSize(16);
						LinearLayout.LayoutParams pm = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);  
						layout.addView(tv, pm);  
						layout.setGravity(Gravity.CENTER);  
						TextView title = new TextView(CaptureActivity.this);  
					      title.setText("扫描成功");  
					      tv.setTextSize(20);
					      title.setGravity(Gravity.CENTER);  
					      
						new AlertDialog.Builder(CaptureActivity.this).setCustomTitle(title) .
						setView(layout).
						setPositiveButton(getString(R.string.confirm), new DialogInterface.OnClickListener() {

							@Override
							public void onClick(DialogInterface dialog, int which) {
								dialog.dismiss();
								if ((source == IntentSource.NONE || source == IntentSource.ZXING_LINK) && lastResult != null) {
									restartPreviewAfterDelay(0L);
								}
//								Intent intent = new Intent(CaptureActivity.this,CodeWebviewActivity.class);
//								intent.putExtra(KidAction.CARD_POINT, bean.getPoint_role_id()+"");
//								CaptureActivity.this.startActivity(intent);
								CaptureActivity.this.finish();
							}
						}).show();
					}else {
						Intent intent = new Intent(CaptureActivity.this,CodeWebviewActivity.class);
						intent.putExtra(KidAction.CARD_POINT, bean.getPoint_role_id()+"");
						CaptureActivity.this.startActivity(intent);
						CaptureActivity.this.finish();
					}
					
					
				}else {
					LinearLayout layout = new LinearLayout(CaptureActivity.this);  
					TextView tv = new TextView(CaptureActivity.this);  
					tv.setText(bean.getDesc());  
					tv.setTextSize(16);
					LinearLayout.LayoutParams pm = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);  
					layout.addView(tv, pm);  
					layout.setGravity(Gravity.CENTER);  
					
					new AlertDialog.Builder(CaptureActivity.this).setTitle("").
					setView(layout).
					setPositiveButton(getString(R.string.confirm), new DialogInterface.OnClickListener() {

						@Override
						public void onClick(DialogInterface dialog, int which) {
							dialog.dismiss();
							if ((source == IntentSource.NONE || source == IntentSource.ZXING_LINK) && lastResult != null) {
								restartPreviewAfterDelay(0L);
							}
						}
					}).show();
//					Toast.makeText(mContext, bean.getDesc(), 1).show();
				}
				isIntent =false;
			}
		}

		@Override
		public boolean refreshError(DataParseError parseError) {
			// TODO Auto-generated method stub
			isIntent =false;
			finishProgress();
			if ((source == IntentSource.NONE || source == IntentSource.ZXING_LINK) && lastResult != null) {
				restartPreviewAfterDelay(0L);
			}
			Toast.makeText(mContext, "失败", 1).show();
			return false;
		}

		@Override
		public void refreshCancel() {
			// TODO Auto-generated method stub
			
		}
		
	}

	public void setListeners() {
		common_title_TV_left.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				CaptureActivity.this.finish();
			}
		});

		common_title_TV_right.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
//				StringUtils.showPictures(CaptureActivity.this, from_photo);
				Intent intent = new Intent(CaptureActivity.this,MarketcardHelpAandIntro.class);
				intent.putExtra(KidAction.IS_GONE_BT, true);
				CaptureActivity.this.startActivity(intent);
			}
		});
	}

	public String parsLocalPic(String path) {
		String parseOk = null;
		Hashtable<EncodeHintType, String> hints = new Hashtable<EncodeHintType, String>();
		hints.put(EncodeHintType.CHARACTER_SET, "UTF8");

		BitmapFactory.Options options = new BitmapFactory.Options();
		options.inJustDecodeBounds = true; // �Ȼ�ȡԭ��С
		Bitmap bitmap = BitmapFactory.decodeFile(path, options);
		options.inJustDecodeBounds = false; // ��ȡ�µĴ�С
		// ���ű�
		int be = (int) (options.outHeight / (float) 200);
		if (be <= 0)
			be = 1;
		options.inSampleSize = be;
		bitmap = BitmapFactory.decodeFile(path, options);
		int w = bitmap.getWidth();
		int h = bitmap.getHeight();
		System.out.println(w + "   " + h);
		RGBLuminanceSource source = new RGBLuminanceSource(bitmap);
		BinaryBitmap bitmap1 = new BinaryBitmap(new HybridBinarizer(source));
		QRCodeReader reader2 = new QRCodeReader();
		Result result;
		try {
			result = reader2.decode(bitmap1, hints);
//			android.util.Log.i("steven", "result:" + result);
			parseOk = result.getText();

		} catch (NotFoundException e) {
			parseOk = null;
		} catch (ChecksumException e) {
			parseOk = null;
		} catch (FormatException e) {
			parseOk = null;
		}
		return parseOk;
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
//		android.util.Log.i("steven", "data.getData()" + data);
		if (data != null) {
			mProgress = new ProgressDialog(CaptureActivity.this);
			mProgress.setMessage("����ɨ��...");
			mProgress.setCancelable(false);
			mProgress.show();
			final ContentResolver resolver = getContentResolver();
			if (requestCode == from_photo) {
				if (resultCode == RESULT_OK) {
					Cursor cursor = getContentResolver().query(data.getData(), null, null, null, null);
					if (cursor.moveToFirst()) {
						photoPath = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA));
					}
					cursor.close();
					new Thread(new Runnable() {
						@Override
						public void run() {
							Looper.prepare();
							String result = parsLocalPic(photoPath);
							if (result != null) {
								Message m = Message.obtain();
								m.what = PARSE_BARCODE_SUC;
								m.obj = result;
								barHandler.sendMessage(m);
							} else {
								Message m = Message.obtain();
								m.what = PARSE_BARCODE_FAIL;
								m.obj = "ɨ��ʧ�ܣ�";
								barHandler.sendMessage(m);
							}
							Looper.loop();
						}
					}).start();
				}

			}
		}
	}

	@Override
	protected void onResume() {
		super.onResume();
		handler = null;
		lastResult = null;
		resetStatusView();
		SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
		SurfaceHolder surfaceHolder = surfaceView.getHolder();
		if (hasSurface) {
			initCamera(surfaceHolder);
		} else {
			surfaceHolder.addCallback(this);
			surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
		}
		restartPreviewAfterDelay(0L);
		inactivityTimer.onResume();
		source = IntentSource.NONE;
		decodeFormats = null;
	}

	@Override
	protected void onPause() {
		if (handler != null) {
			handler.quitSynchronously();
			handler = null;
		}
		inactivityTimer.onPause();
		cameraManager.closeDriver();
		if (!hasSurface) {
			SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
			SurfaceHolder surfaceHolder = surfaceView.getHolder();
			surfaceHolder.removeCallback(this);
		}
		super.onPause();
	}

	@Override
	protected void onDestroy() {
		inactivityTimer.shutdown();
		if (mProgress!= null) {
			mProgress.dismiss();
		}
		super.onDestroy();
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		switch (keyCode) {
		case KeyEvent.KEYCODE_BACK:
			if ((source == IntentSource.NONE || source == IntentSource.ZXING_LINK) && lastResult != null) {
				restartPreviewAfterDelay(0L);
				return true;
			}
			break;
		case KeyEvent.KEYCODE_VOLUME_DOWN:
			cameraManager.setTorch(false);
			return true;
		case KeyEvent.KEYCODE_VOLUME_UP:
			cameraManager.setTorch(true);
			return true;
		}
		return super.onKeyDown(keyCode, event);
	}

	// �����ʼ�����棬���ó�ʼ�����
	@Override
	public void surfaceCreated(SurfaceHolder holder) {
		if (holder == null) {
			Log.e(TAG, "*** WARNING *** surfaceCreated() gave us a null surface!");
		}
		if (!hasSurface) {
			hasSurface = true;
			initCamera(holder);
		}
	}

	@Override
	public void surfaceDestroyed(SurfaceHolder holder) {
		hasSurface = false;
	}

	@Override
	public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {

	}

	private static ParsedResult parseResult(Result rawResult) {
		return ResultParser.parseResult(rawResult);
	}

	// ������ά��
	public void handleDecode(Result rawResult, Bitmap barcode) {
		inactivityTimer.onActivity();
		lastResult = rawResult;

		ResultHandler resultHandler = new ResultHandler(parseResult(rawResult));

		boolean fromLiveScan = barcode != null;
		if (barcode == null) {
//			android.util.Log.i("steven", "rawResult.getBarcodeFormat().toString():" + rawResult.getBarcodeFormat().toString());
//			android.util.Log.i("steven", "resultHandler.getType().toString():" + resultHandler.getType().toString());
//			android.util.Log.i("steven", "resultHandler.getDisplayContents():" + resultHandler.getDisplayContents());
		} else {
			Log.e("CaptureActivity", "--CaptureActivity--1");
			showDialog(resultHandler.getDisplayContents().toString());
		}
	}

	// ��ʼ�������CaptureActivityHandler����
	private void initCamera(SurfaceHolder surfaceHolder) {
		if (surfaceHolder == null) {
			throw new IllegalStateException("No SurfaceHolder provided");
		}
		if (cameraManager.isOpen()) {
			Log.w(TAG, "initCamera() while already open -- late SurfaceView callback?");
			return;
		}
		try {
			cameraManager.openDriver(surfaceHolder);
			if (handler == null) {
				handler = new CaptureActivityHandler(this, decodeFormats, characterSet, cameraManager);
			}
		} catch (IOException ioe) {
			Log.w(TAG, ioe);
			displayFrameworkBugMessageAndExit();
		} catch (RuntimeException e) {
			Log.w(TAG, "Unexpected error initializing camera", e);
			displayFrameworkBugMessageAndExit();
		}
	}

	private void displayFrameworkBugMessageAndExit() {
		AlertDialog.Builder builder = new AlertDialog.Builder(this);
		builder.setTitle(getString(R.string.app_name));
		builder.setMessage(getString(R.string.msg_camera_framework_bug));
		builder.setPositiveButton(R.string.confirm, new FinishListener(this));
		builder.setOnCancelListener(new FinishListener(this));
		builder.show();
	}

	public void restartPreviewAfterDelay(long delayMS) {
		if (handler != null) {
			handler.sendEmptyMessageDelayed(R.id.restart_preview, delayMS);
		}
		resetStatusView();
	}

	private void resetStatusView() {
//		statusView.setText(R.string.msg_default_status);
		statusView.setVisibility(View.GONE);
		viewfinderView.setVisibility(View.VISIBLE);
		lastResult = null;
	}

	public void drawViewfinder() {
		viewfinderView.drawViewfinder();
	}

}
